package de.tudarmstadt.ukp.muip.fibqdojo.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;

public class ConstantLoader {

    /**
     * Loads the contents of the specified line by line using UTF-8 encoding.
     * Each line will be considered as constant.
     */
    public static List<String> loadConstantsFrom(String file) {
        return loadConstantsFrom(file, "UTF-8");
    }

    /**
     * Loads the contents of the specified line by line using the specified
     * encoding. Each line will be considered as constant.
     */
    public static List<String> loadConstantsFrom(String file, String encoding) {
        List<String> symbols = new LinkedList<String>();
        Properties properties = new Properties();
        try {
            properties.load(new InputStreamReader(new FileInputStream(file), encoding));
            for (Object o : properties.keySet()) {
                String string = (String) o;
                symbols.add(string);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return symbols;
    }

}
